@echo off
set build_type=Release;Debug
set opencv_root=%cd%\opencv
set opencv_version=400

if exist build (rmdir /S /Q build)
mkdir build
cd build
cmake .. ^
-G"Visual Studio 15 2017 Win64" ^
-DCMAKE_CONFIGURATION_TYPES=%build_type% ^
-DOPENCV_ROOT=%opencv_root% ^
-DOPENCV_VERSION=%opencv_version%

for %%t in (%build_type%) do (call :copy_dll %%t)
pause

:copy_dll
  mkdir %1
  if "%1" == "Release" (set sfx=) else (set sfx=d)
  copy %opencv_root%\bin\opencv_world%opencv_version%%sfx%.dll %1\
  goto :eof